package meihua.stopcarapp.presenter;

import android.util.Log;

import meihua.mylibrary.baserx.RxSubscriber;
import meihua.stopcarapp.R;
import meihua.stopcarapp.bean.UserEntity;
import meihua.stopcarapp.presenter.contract.UserInfoContract;

/**
 * Created by 小杜 on 2017/5/10.
 */

public class UserInfoPresenter extends UserInfoContract.Presenter {

    @Override
    public void getUserNickNameRequest(String user_phone, String user_id, String user_nickname) {
        mRxManage.add(mModel.getUserNickName(user_phone,user_id,user_nickname)
                .subscribe(new RxSubscriber<String>(mContext,false) {
                    @Override
                    public void onStart() {
                        super.onStart();
                        mView.showLoading(mContext.getString(R.string.loading));
                    }
                    @Override
                    protected void _onNext(String user_nickname) {
                        Log.d("ligaozeng","发送验证码");
                        mView.returnUserNickName(user_nickname);
                        mView.stopLoading();
                    }
                    @Override
                    protected void _onError(String message) {
                        Log.d("ligaozeng","服务器错误:"+message);
                    }
                }));
    }

    @Override
    public void getUserSexRequest(String user_phone, String user_sex) {
        mRxManage.add(mModel.getUserSex(user_phone,user_sex)
                .subscribe(new RxSubscriber<UserEntity>(mContext,false) {
                    @Override
                    public void onStart() {
                        super.onStart();
                        mView.showLoading(mContext.getString(R.string.loading));
                    }
                    @Override
                    protected void _onNext(UserEntity user) {
                        Log.d("ligaozeng","发送验证码");
                        mView.returnUserSex(user);
                        mView.stopLoading();
                    }
                    @Override
                    protected void _onError(String message) {
                        Log.d("ligaozeng","服务器错误:"+message);
                    }
                }));
    }

    @Override
    public void getUserPhoneRequest(String user_phone, String user_id) {
        mRxManage.add(mModel.getUserPhone(user_phone,user_id)
                .subscribe(new RxSubscriber<String>(mContext,false) {
                    @Override
                    public void onStart() {
                        super.onStart();
                        mView.showLoading(mContext.getString(R.string.loading));
                    }
                    @Override
                    protected void _onNext(String str) {
                        Log.d("ligaozeng","发送验证码");
                        mView.returnUserPhone(str);
                        mView.stopLoading();
                    }
                    @Override
                    protected void _onError(String message) {
                        Log.d("ligaozeng","服务器错误:"+message);
                    }
                }));
    }

    @Override
    public void getUserCardRequest(String user_id, String user_phone, String user_idcard, String user_name) {

    }

    @Override
    public void getUserPlateNumberRequest(String user_phone, String user_id, String user_carid) {
        mRxManage.add(mModel.getUserPlateNumber(user_phone,user_id,user_carid)
                .subscribe(new RxSubscriber<String>(mContext,false) {
                    @Override
                    public void onStart() {
                        super.onStart();
                        mView.showLoading(mContext.getString(R.string.loading));
                    }
                    @Override
                    protected void _onNext(String str) {
                        Log.d("ligaozeng","发送验证码");
                        mView.returnUserPhone(str);
                        mView.stopLoading();
                    }
                    @Override
                    protected void _onError(String message) {
                        Log.d("ligaozeng","服务器错误:"+message);
                    }
                }));
    }

    @Override
    public void getUserYtTitleRequest(String user_phone) {

    }

    @Override
    public void getUserQuitRequest(String user_phone, String user_state) {

    }
}
